<?php
//Checkout -> 04 Order
//checkout04order.php
  if(!isset($_SESSION['shoppingBag'])) {
    $_SESSION['shoppingBag'] = array();
  }

  sort($_SESSION['shoppingBag']);
  $bagUnique = array_unique($_SESSION['shoppingBag']);
  $bagCount = array_count_values($_SESSION['shoppingBag']);

  $bagProd = array();
  $bagProd = bag_construction($db);

  sort($_SESSION['shoppingBag']);
  $bagUnique = array_unique($_SESSION['shoppingBag']);
  $bagCount = array_count_values($_SESSION['shoppingBag']);

  //Get Address
  $tmpAddr[0]['address_fullname'] = $_SESSION['checkOut']['address-fullname'];
  $tmpAddr[0]['address_line1'] = $_SESSION['checkOut']['address-street1'];
  $tmpAddr[0]['address_line2'] = $_SESSION['checkOut']['address-street2'];
  $tmpAddr[0]['address_city'] = $_SESSION['checkOut']['address-city'];
  $tmpAddr[0]['address_region'] = $_SESSION['checkOut']['address-state'];
  $tmpAddr[0]['address_postcode'] = $_SESSION['checkOut']['address-postcode'];
  $tmpAddr[0]['address_country'] = $_SESSION['checkOut']['address-country'];
  $tmpAddr[0]['address_phone'] = $_SESSION['checkOut']['address-phone'];

  //Get Customer
  $tmpCust[0]['customer_email'] = $_SESSION['checkOut']['email-address'];
  $tmpCust[0]['customer_loginby'] = "";

  //Get Postage
  $cols = NULL;
  $conds = array();
  $conds[] = array(1);
  $conds[] = array(0);
  $conds[] = array($tmpAddr[0]['address_country']);
  $query = $db->db_select("postage", $cols, $conds);
  $result = $db->database->query($query);
  $tmpPostg = $result->fetchAll(SQLITE_ASSOC);
?>
          <p><a href="<?php echo $_SERVER['PHP_SELF']."?do=contacts"; ?>" class="btn btn-mini btn-inverse">Change Contacts</a></p>
          <?php printOrderTable($tmpAddr, $tmpCust, $bagProd, $tmpPostg, $bagCount); ?>
          <p><a href="<?php echo $_SERVER['PHP_SELF']."?do=bag"; ?>" class="btn btn-mini btn-inverse">Change Bag</a></p>
          <div class="pull-right">
            <a href="<?php echo $_SERVER['PHP_SELF']."?do=pay"; ?>" class="btn btn-success">Continue &raquo;</a>
          </div>
<?php
?>